VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmINV110 
   BackColor       =   &H8000000D&
   Caption         =   " INV110"
   ClientHeight    =   4215
   ClientLeft      =   1335
   ClientTop       =   1455
   ClientWidth     =   9180
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   4215
   ScaleWidth      =   9180
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   372
      Left            =   5040
      Top             =   0
      Visible         =   0   'False
      Width           =   1692
      _ExtentX        =   2990
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   372
      Left            =   3120
      Top             =   0
      Visible         =   0   'False
      Width           =   1452
      _ExtentX        =   2566
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   2040
      Left            =   336
      TabIndex        =   10
      Top             =   1392
      Width           =   8484
      Begin MSDataListLib.DataCombo cboWHCID 
         Bindings        =   "frmINV110.frx":0000
         Height          =   288
         Left            =   2772
         TabIndex        =   16
         Top             =   1356
         Width           =   3576
         _ExtentX        =   6297
         _ExtentY        =   556
         _Version        =   393216
         Enabled         =   0   'False
         Locked          =   -1  'True
         ListField       =   "CNONM"
         BoundColumn     =   "CNCID"
         Text            =   ""
      End
      Begin VB.TextBox txtWMDSC 
         Enabled         =   0   'False
         Height          =   720
         Left            =   2796
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         TabIndex        =   15
         Top             =   504
         Width           =   4188
      End
      Begin VB.TextBox txtWMWHC 
         Enabled         =   0   'False
         Height          =   288
         Left            =   2796
         Locked          =   -1  'True
         TabIndex        =   14
         Top             =   60
         Width           =   1008
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ware house code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   5
         Left            =   1200
         TabIndex        =   13
         Top             =   135
         Width           =   1515
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Description"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   3
         Left            =   1605
         TabIndex        =   12
         Top             =   495
         Width           =   1020
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Company"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   4
         Left            =   1755
         TabIndex        =   11
         Top             =   1365
         Width           =   840
      End
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "&Delete"
      Height          =   372
      Left            =   4632
      TabIndex        =   7
      Top             =   3588
      Width           =   960
   End
   Begin VB.CommandButton cmdAddnew 
      Caption         =   "&New"
      Height          =   372
      Left            =   384
      TabIndex        =   4
      Top             =   3588
      Width           =   996
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   372
      Left            =   1464
      TabIndex        =   3
      Top             =   3588
      Width           =   948
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   372
      Left            =   2496
      TabIndex        =   2
      Top             =   3588
      Width           =   984
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   372
      Left            =   3540
      TabIndex        =   1
      Top             =   3600
      Width           =   1032
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   372
      Left            =   5652
      TabIndex        =   0
      Top             =   3588
      Width           =   1080
   End
   Begin MSDataListLib.DataCombo cboWMWHC 
      Bindings        =   "frmINV110.frx":0015
      Height          =   285
      Left            =   4380
      TabIndex        =   8
      Top             =   960
      Width           =   3090
      _ExtentX        =   5450
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "WMDSC"
      BoundColumn     =   "WMWHC"
      Text            =   ""
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Chose Warehouse Review"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080FFFF&
      Height          =   225
      Index           =   2
      Left            =   1920
      TabIndex        =   9
      Top             =   975
      Width           =   2370
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "INV110"
      BeginProperty Font 
         Name            =   "VNI-Present"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   468
      Index           =   0
      Left            =   36
      TabIndex        =   6
      Top             =   24
      Width           =   1680
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Warehouse Master Mainternent"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   495
      Index           =   1
      Left            =   1770
      TabIndex        =   5
      Top             =   420
      Width           =   6810
   End
End
Attribute VB_Name = "frmINV110"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OldWMWHC As String
Sub ButtonStatus()
cmdAddnew.Enabled = Not ISEDITING
cmdEdit.Enabled = Not ISEDITING
cmdSave.Enabled = ISEDITING ' And txtIMITN <> ""
cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
cmdCancel.Enabled = ISEDITING
'txtIMITN.Locked = Not ISADDING ' Lock item code tru truong hop ISADDING=true
'txtDepartment.Enabled = ISEDITING
'cboDepartment.Visible = Not ISADDING
'txtDepartmentID.Visible = ISADDING
End Sub

Private Sub Control(GT As Variant)
    
    txtWMWHC.Enabled = GT
    txtWMDSC.Enabled = GT
    cboWHCID.Enabled = GT
      
    

    txtWMWHC.Locked = Not GT
    txtWMDSC.Locked = Not GT
    cboWHCID.Locked = Not GT
    
    
    cboWMWHC.Enabled = Not GT
    cboWMWHC.Locked = GT
End Sub
Private Sub WriteToScreen(tri As Byte)
If tri = 0 Then 'gan rong
        
        
        txtWMWHC = ""
        txtWMDSC = ""
        cboWHCID.BoundText = "'"
       
Else
        Dim TBL As ADODB.Recordset
        Set TBL = New ADODB.Recordset
        TBL.Open "  Select IWM.*From IWM where  WMWHC ='" & cboWMWHC.BoundText & "'", DBconn, adOpenKeyset, adLockOptimistic, adCmdText
        If TBL.EOF = False Then
            txtWMWHC = IIf(IsNull(TBL!wmwhc), "", TBL!wmwhc)
            txtWMDSC = IIf(IsNull(TBL!WMDSC), "", TBL!WMDSC)
            cboWHCID.BoundText = IIf(IsNull(TBL!whcid), "", TBL!whcid)
        Else
            cboWMWHC.BoundText = ""
            txtWMWHC = ""
            txtWMDSC = ""
            cboWHCID.BoundText = "'"
        End If
        TBL.Close
End If
OldWMWHC = txtWMWHC
End Sub
Private Sub WriteToFile(tri As Byte)
Dim SQLInsert As String
If tri = 0 Then
    SQLInsert = " INSERT INTO IWM " & _
                  "(WMWHC,WMDSC,WHCID) " & _
                "VALUES " & _
                  "('" & Left(txtWMWHC, 2) & "', '" & Left(txtWMDSC, 30) & "', '" & cboWHCID.BoundText & "')"
 Else
    SQLInsert = "UPDATE IWM SET WMWHC = '" & Left(txtWMWHC, 2) & "', WMDSC ='" & Left(txtWMDSC, 30) & "', " & _
                "WHCID ='" & cboWHCID.BoundText & "' WHERE WMWHC ='" & OldWMWHC & "'"
             
             
End If

Set cmdExecute = New ADODB.Command
Set cmdExecute.ActiveConnection = DBconn
cmdExecute.CommandText = SQLInsert
cmdExecute.Execute

End Sub


Private Sub cboWHCID_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    cmdSave.SetFocus
    
End If

End Sub

Private Sub cboWMWHC_Click(Area As Integer)
If Area = 2 Then
    WriteToScreen (1)
End If

End Sub

Private Sub cmdAddnew_Click()
ISADDING = True
ISEDITING = True
WriteToScreen (0)
Control (True)
' Ham Gan tri man hinh
ButtonStatus
txtWMWHC.SetFocus
    


End Sub

Private Sub cmdCancel_Click()
' Gan tri man nhinh
ISADDING = False
ISEDITING = False
Control (False)
ButtonStatus
txtWMWHC = cboWMWHC.BoundText
WriteToScreen (1)

End Sub

Private Sub cmdDelete_Click()
ISADDING = False
ISEDITING = False
' Ham delete theo Item chon
Dim SQL As String
SQL = "DELETE FROM IWM WHERE wmwhc = '" & txtWMWHC & "'"

Set cmdExecute = New ADODB.Command
Set cmdExecute.ActiveConnection = DBconn
cmdExecute.CommandText = SQL
cmdExecute.Execute
Adodc1.Refresh
WriteToScreen (0)
ButtonStatus

End Sub

Private Sub cmdEdit_Click()
ISEDITING = True
' Ham gan tri man hinh
ISADDING = False
ISEDITING = True
Control (True)

ButtonStatus

End Sub

Private Sub cmdExit_Click()
Unload frmINV110
End Sub

Private Sub cmdSave_Click()
' Ham Save tri vao file
'Dim tbl_ChapNhan As ADODB.Recordset
'Set tbl_ChapNhan = New ADODB.Recordset
'tbl_ChapNhan.Open "  Select IIM.*From IIM ", DBconn, adOpenKeyset, adLockOptimistic, adCmdText
'tbl_ChapNhan.Close
If ISADDING = False Then
    WriteToFile (1)
Else
    WriteToFile (0)
End If
Adodc1.Refresh
Control (False)
'''''''''''
ISADDING = False
ISEDITING = False

ButtonStatus

End Sub

Private Sub Form_Load()
BIENCHUNG
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "IWM" 'Warehour master
Adodc1.Refresh

Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdTable
Adodc2.RecordSource = "ACN" 'company profile
Adodc2.Refresh
ISADDING = False
ISEDITING = False
ButtonStatus

End Sub

Private Sub txtWMDSC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    cboWHCID.SetFocus
    
End If

End Sub

Private Sub txtWMWHC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If ValidMaso(OldWMWHC, txtWMWHC, "IWM", " WMWHC='" & txtWMWHC & "'") Then
        MsgBox "This code is already exist"
        txtWMWHC.SetFocus
    Else
         txtWMDSC.SetFocus
    End If
   
End If

End Sub



